﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeTop.复习九月份
{
    public class Solution55
    {
        public bool CanJump(int[] nums)
        {

            int MaxRange = 0;
            for (int i = 0; i < nums.Length; i++)
            {


                Console.WriteLine("i:   "+ i + "MaxRange:   " + MaxRange);
                if (MaxRange < i)
                {
                    return false;
                }
                else
                {

                    MaxRange = Math.Max(MaxRange, i + nums[i]);
                }



            }
            return true;
        }
    }

    class Program55
    {

        static void Main55(string[] args)
        {


            Solution55 solution = new Solution55();
            int[] nums = [2, 3, 1, 1, 4];
         bool res=   solution.CanJump(nums);
            Console.WriteLine(res);
        }


    }
}
